package com.cictec.middleware.core.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.cictec.middleware.commons.utils.Result;
import com.cictec.middleware.commons.utils.ResultUtil;
import com.cictec.middleware.core.entity.WarnMsg;
import com.cictec.middleware.core.service.WarnMsgService;

@RestController
public class BusWarnController {

	private static Logger logger = LoggerFactory.getLogger(BusWarnController.class);

	@Autowired
	private WarnMsgService warnMsgService;

	/**
	 * 【数据库】获取所有车辆信息
	 * 
	 * @return
	 */
	@RequestMapping(value = "/dc/warn/save")
	public Result saveWarn(@RequestBody WarnMsg warnMsg) {
		logger.debug("保存报警信息:{}", JSON.toJSONString(warnMsg));
		warnMsgService.saveWarn(warnMsg);
		return ResultUtil.getSuccessResult(warnMsg.getWarnUuid());
	}
	
	@RequestMapping(value = "/dc/warn/delete")
	public Result deleteWarn(@RequestParam("date") String date, @RequestParam("warnType") String warnType,
			@RequestParam("busUuid") String busUuid){
		
		warnMsgService.deleteWarn(date, warnType, busUuid);
		return ResultUtil.getSuccessResult();
	}

}
